import { useDebounceFn } from '@vueuse/core'

export const setDomFontSize = (): void => {
  const width = document.documentElement.clientWidth || document.body.clientWidth
  const fontSize = `${String((width <= 200 ? 1200 : width) / 10)}px`
  document.getElementsByTagName('html')[0].style.fontSize = fontSize
}

const setDomFontSizeDebounce = useDebounceFn(setDomFontSize, 400)
window.addEventListener('resize', setDomFontSizeDebounce as (this: Window, ev: UIEvent) => any) // 浏览器加入收缩监听防抖，重新计算rem配置
